package com.cspg.ssss.vo.convert;

import com.cspg.ssss.domain.DwdgbmGradeViewEntity;
import com.cspg.ssss.domain.GsdgdwGradeViewEntity;
import com.cspg.ssss.domain.UserDetailInfoEntity;
import com.cspg.ssss.vo.ProblemGradeViewVo;
import com.cspg.ssss.vo.UserInfoVo;

import java.util.ArrayList;
import java.util.List;

public class ProblemGradeViewVoConvert {
    public static ProblemGradeViewVo ConvertFromGsdgdw(GsdgdwGradeViewEntity en){

        ProblemGradeViewVo vo = new ProblemGradeViewVo();
        vo.setId(en.getId());
        vo.setDepartment_name(en.getDepartment_name());
        vo.setPerson_name(en.getPerson_name());
        vo.setInstance_title(en.getInstance_title());
        vo.setCreatea_time(en.getCreatea_time());
        vo.setIsover(en.getIsover());
        vo.setDatafrom(en.getDatafrom());
        vo.setDytxdy(en.getDytxdy());
        vo.setDytxys(en.getDytxys());
        vo.setGlhj(en.getGlhj());
        vo.setSfzdbl(en.getSfzdbl());
        vo.setSfslwt(en.getSfslwt());
        vo.setZylb(en.getZylb());
        vo.setKhbm(ConvertDeptToPath(en.getGskhbm()));
        vo.setBmmc(ConvertDeptToPath(en.getBmmc()));
        vo.setWtlb(en.getWtlb());
        vo.setWtms(en.getWtms());
        vo.setXh(en.getXh());
        vo.setDwmc(ConvertDeptToPath(en.getDwmc()));
        vo.setSscm(en.getSscm());
        vo.setWtfxr(en.getWtfxr());
        vo.setGbyy(en.getGbyy());
        vo.setWtfxsj(en.getWtfxsj());
        vo.setYwsx(en.getYwsx());
        vo.setWtyzcd(en.getWtyzcd());
        vo.setZgjy(en.getZgjy());
        vo.setWtfxfs(en.getWtfxfs());
        vo.setCheck_item(en.getCheck_item());
        vo.setScore(en.getScore());
        vo.setCheck_userid(en.getCheck_userid());
        vo.setCheck_username(en.getCheck_username());
        vo.setGrade_time(en.getGrade_time());
        vo.setProblem_status(en.getProblem_status());
        vo.setBatch_id(en.getBatch_id());
        vo.setGrade_dept(en.getGrade_dept());

        return vo;
    }

    public static ProblemGradeViewVo ConvertFromDwdgbm(DwdgbmGradeViewEntity en){

        ProblemGradeViewVo vo = new ProblemGradeViewVo();
        vo.setId(en.getId());
        vo.setDepartment_name(en.getDepartment_name());
        vo.setPerson_name(en.getPerson_name());
        vo.setInstance_title(en.getInstance_title());
        vo.setCreatea_time(en.getCreatea_time());
        vo.setIsover(en.getIsover());
        vo.setDatafrom(en.getDatafrom());
        vo.setDytxdy(en.getDytxdy());
        vo.setDytxys(en.getDytxys());
        vo.setGlhj(en.getGlhj());
        vo.setSfzdbl(en.getSfzdbl());
        vo.setSfslwt(en.getSfslwt());
        vo.setZylb(en.getZylb());
        vo.setKhbm(ConvertDeptToPath(en.getGdwkhbm()));
        vo.setBmmc(ConvertDeptToPath(en.getBmmc()));
        vo.setWtlb(en.getWtlb());
        vo.setWtms(en.getWtms());
        vo.setXh(en.getXh());
        vo.setDwmc(ConvertDeptToPath(en.getDwmc()));
        vo.setSscm(en.getSscm());
        vo.setWtfxr(en.getWtfxr());
        vo.setGbyy(en.getGbyy());
        vo.setWtfxsj(en.getWtfxsj());
        vo.setYwsx(en.getYwsx());
        vo.setWtyzcd(en.getWtyzcd());
        vo.setZgjy(en.getZgjy());
        vo.setWtfxfs(en.getWtfxfs());
        vo.setCheck_item(en.getCheck_item());
        vo.setScore(en.getScore());
        vo.setCheck_userid(en.getCheck_userid());
        vo.setCheck_username(en.getCheck_username());
        vo.setGrade_time(en.getGrade_time());
        vo.setProblem_status(en.getProblem_status());
        vo.setBatch_id(en.getBatch_id());
        vo.setGrade_dept(en.getGrade_dept());

        return vo;
    }

    /**
     * 将部门路径由/分隔改成->分隔，去掉超高压前缀
     * @param deptPath
     * @return
     */
    private static String ConvertToDeptPath(String deptPath){
        if(deptPath.startsWith("超高压输电公司/") == false){
            return deptPath;
        }
        String newpath = deptPath.substring(8).replaceAll("/","->");
        return newpath;
    }

    /**
     * 将部门路径由->分隔改成/分隔，加上超高压前缀
     * @param deptPath
     * @return
     */
    private static String ConvertDeptToPath(String deptPath){
        String newpath = deptPath.replaceAll("->","/");
        newpath = "超高压输电公司/"+newpath;
        return newpath;
    }

    public static List<ProblemGradeViewVo> ConvertListGsdgdw(List<GsdgdwGradeViewEntity> enList){
        List<ProblemGradeViewVo> retList = new ArrayList<ProblemGradeViewVo>();
        for(GsdgdwGradeViewEntity en : enList){
            ProblemGradeViewVo vo = new ProblemGradeViewVo();
            vo = ConvertFromGsdgdw(en);
            vo.setProblem_type(0);
            retList.add(vo);
        }

        return retList;
    }

    public static List<ProblemGradeViewVo> ConvertListDwdgbm(List<DwdgbmGradeViewEntity> enList){
        List<ProblemGradeViewVo> retList = new ArrayList<ProblemGradeViewVo>();
        for(DwdgbmGradeViewEntity en : enList){
            ProblemGradeViewVo vo = new ProblemGradeViewVo();
            vo = ConvertFromDwdgbm(en);
            vo.setProblem_type(1);
            retList.add(vo);
        }

        return retList;
    }
}
